/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package xpath;

import java.io.File;
import java.io.FileInputStream;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathFactory;
import org.w3c.dom.Document;

/**
 *
 * @author Rishav
 */
public class Xpath {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws Exception{
        // TODO code application logic here
        
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        
        FileInputStream file = new FileInputStream(new File("files/ca.xml"));
                 
            DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
             builderFactory.setNamespaceAware(false);
            DocumentBuilder builder =  builderFactory.newDocumentBuilder();
             
            //Document xmlDocument = builder.parse(file);
            XPath xPath =  XPathFactory.newInstance().newXPath();
            for(String l:Xslt.genrateXPath(file)){
                System.out.println(l);
            }
            //String expression = "substring(/Document/CorpActnNtfctn/CorpActnOptnDtls[OptnTp/Cd='SECU']/FrctnDspstn/Cd/text(),1,2)";
            //System.out.println(expression);
            //String email = xPath.compile(expression).evaluate(xmlDocument);
            //System.out.println("Val="+email);
    }
    
}
